package com.example.homework1;

import jakarta.servlet.ServletRequest;
import jakarta.servlet.ServletResponse;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.*;

import java.io.*;

import java.time.LocalDateTime;

@WebServlet(name = "date-servlet", value = "/date-servlet")
public class ShowTime extends HttpServlet {
    private LocalDateTime dateTime;

    public void init(){
        dateTime = LocalDateTime.now();
    }


    public void doGet(HttpServletRequest request , HttpServletResponse response) throws IOException {

        response.setContentType("text/html");

        PrintWriter out = response.getWriter();
        out.println("<html><head>");
        out.println("<title>Show Time</title>");
        out.println("</head>");
        out.println("<body><h1>Here is the time:<br>");
        out.println(dateTime+"</h1></body></html>");
    }
    public void destroy(){}
}
